package com.zx.servicelearn.utils;

import android.app.ActivityManager;
import android.content.Context;

import java.util.List;

/**
 * Created by zhoux on 2018/1/17.
 * 注释：
 */

public class MyUtils {
    public static String getProcessName(Context context, int processId) {
        ActivityManager actMgr = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningAppProcessInfo> appList = actMgr.getRunningAppProcesses();
        for (ActivityManager.RunningAppProcessInfo info : appList) {
            if (info.pid == processId) {
                return info.processName;
            }
        }
        return "unknown";
    }
}
